<?php
require_once 'Service/Condition/ZendDb/Group.php';

/**
 * Equals condition.
 *
 * @author baziak
 */
class Service_Condition_ZendDb_Empty
    extends Service_Condition_ZendDb_Group
{
    public function __construct($params)
    {
        parent::__construct(Service_Condition_ZendDb_Group::TYPE_OR);

        if (is_string($params)) {
            $field = $params;
        } elseif (is_array($params)) {
            $field = isset($params['field']) ? $params['field'] : null;
        }

        if (empty($field)) {
            require_once 'Service/Condition/Exception.php';
            throw new Service_Condition_Exception('Field is not specified.');
        }

        require_once 'Service/Condition/ZendDb/Equals.php';

        $this->add(new Service_Condition_ZendDb_Equals(array(
            'field' => $field, 'value' => ''
        )));

        require_once 'Service/Condition/ZendDb/IsNull.php';

        $this->add(new Service_Condition_ZendDb_IsNull($field));
    }


}